Skip to content

properly handle revision based_on field #6580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

escattone
Copy link
Contributor

@escattone escattone commented Mar 21, 2025

mozilla/sumo#2262

Notes

This PR takes care of properly handling the based_on field within the delete user pipeline.

  • Revisions of parent documents
    • The based_on of these revisions currently gets set to either null (if no prior revision yet exists) or some other prior revision within the same document. It's never used after that, but it does get set. So when we delete un-approved revisions of parent documents, we risk deleting not only other revisions via the based_on cascade, but the entire parent document because the chain of cascades often reaches the current_revision, which then pulls in the document.
    • In this PR, if we're about to delete an un-approved revision that is the based_on of one or more revisions of parent documents, we prevent the cascade deletion of these by setting their based_on to None.
  • Revisions of translations
    • The based_on of these revisions is always set to a revision within the translation's parent, but should always refer to an approved revision.
    • No changes here. We allow the cascade delete via based_on because if its based_on refers to an un-approved revision, it should be deleted.

@escattone escattone changed the title properly handle revision based_on field properly handle revision based_on field Mar 21, 2025
@escattone escattone requested a review from akatsoulas March 21, 2025 16:39
@escattone escattone force-pushed the handle-based-on-during-user-deletion-2262 branch from 59305d2 to 5e3a68c Compare March 21, 2025 21:52
@akatsoulas
Copy link
Collaborator

akatsoulas commented Mar 26, 2025

I would prefer to avoid having based_on revisions set to null upon deletion to avoid dangling revisions. How about treating this like a linked list of sorts?

  • Identify all revisions that reference the to-be-deleted revisions
  • Get the based_on value of the to-be-deleted revision
  • Update the referencing revision to point to this predecessor
  • If the to-be-deleted revision has no predecessor or it's the base of a translation set based_on=NULL
  • Add a textfield/jsonfield to populate on deletion that explains the changes to the revision, something like previously was based on revision_id X created on Date. Modified during user deletion Y

Ideally this approach is simple and consistent and preserver the revision history and documents the changes.

@escattone escattone force-pushed the handle-based-on-during-user-deletion-2262 branch 3 times, most recently from 1c26f68 to bc4378e Compare March 27, 2025 23:50
@escattone escattone force-pushed the handle-based-on-during-user-deletion-2262 branch from bc4378e to e3c02cd Compare March 28, 2025 15:56
@akatsoulas akatsoulas merged commit 95ba7f5 into mozilla:main Mar 31, 2025
2 checks passed
@escattone escattone deleted the handle-based-on-during-user-deletion-2262 branch March 31, 2025 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants